package org.example.c2;

import lombok.extern.slf4j.Slf4j;

/**
 * @author liu-rui
 * @date 2020/6/1 上午11:26
 * @description 实践InheritableThreadLocal
 * @since
 */
@Slf4j
public class Demo4 {
    public static void main(String[] args) {
        InheritableThreadLocal<String> inheritableThreadLocal = new InheritableThreadLocal<>();
        ThreadLocal<String> threadLocal = new ThreadLocal<>();

        inheritableThreadLocal.set("inheritableThreadLocal");
        threadLocal.set("threadLocal");

        new Thread(() -> {
            log.info("threadLocal 值为：{}", threadLocal.get());
            log.info("inheritableThreadLocal 值为：{}", inheritableThreadLocal.get());
        }, "t1").start();
    }
}
